#ifndef FTCOLORDIALOG_H
#define FTCOLORDIALOG_H

#include <QtGui>

class FTColorDialog : public QWidget
{
    Q_OBJECT
public:
    explicit FTColorDialog(QWidget *parent = 0);
    explicit FTColorDialog(const QColor&, QWidget *parent = 0);

    void paintEvent(QPaintEvent *);
    void mouseReleaseEvent(QMouseEvent *);
    void mousePressEvent(QMouseEvent *);
    void mouseMoveEvent(QMouseEvent *);
    void resizeEvent(QResizeEvent *);

    QColor currentColor() const;
    void setCurrentColor(const QColor&);

    QSize sizeHint() const;
    QSize minimumSizeHint() const;

signals:

public slots:

private:
    bool mouse_down;
    void initialize(const QColor& c = QColor());

    QColor _currentColor;

    QRect hue_sat_rect;
    QRect value_rect;
    QRect preview_rect;
    QRect preview_txt_rect;
    QRect hue_sat_txt_rect;
    QRect value_txt_rect;
    QImage value_image;
    QString preview_text;

    void buildValueImage();

    QPoint hueSatToPoint();
    void pointToHueSat( const QPoint& );

    int valueToPoint();
    void pointToValue(int);

private:
    static bool imagesCreated;
    static QImage hue_sat_image;
};

#endif // FTCOLORDIALOG_H
